package com.lixinyue.exer;

public class Student {
    int number;
    int state;
    int score;
    public String info()
    {
        return "学号"+number+"，年级"+state+",成绩"+score;
    }
//遍历数组
    public void thro(Student[] stus)
    {
        for (int i = 0; i <stus.length ; i++) {
            System.out.println(stus[i].info());
        }
        System.out.println("**********************************");
    }
    public void searchState(Student[] stus,int state)
    {
        for (int i = 0; i <stus.length ; i++) {
            if (stus[i].state==state)
            {
                System.out.println(stus[i].info());
            }
        }
        System.out.println("**********************************");
    }

    /**
     * @Description 给数组排序
     * @param stus
     */
    public void sort(Student[] stus)
    {
        for (int i = 0; i <stus.length-1; i++) {
            for (int j = 0; j < stus.length-1-i; j++) {

                if(stus[j].score<stus[j+1].score)
                {
                    Student tmp=stus[j];
                    stus[j]=stus[j+1];
                    stus[j+1]=tmp;
                }
            }
        }

    }


}
